//
//  VipBottomAlertView.m
//  fitnessmanage
//
//  Created by wujian on 2017/12/6.
//  Copyright © 2017年 zongquankeji. All rights reserved.
//

#import "VipBottomAlertView.h"

@implementation VipBottomAlertView

-(id)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        UIView *alphaView = [[UIView alloc] init];
        alphaView.backgroundColor = [CSBlackColor colorWithAlphaComponent:0.4];
        [self addSubview:alphaView];
        self.alphaView = alphaView;
        
        /**
         白色
         */
        UIView *whiteView = [[UIView alloc] init];
        whiteView.backgroundColor = CSWhiteColor;
        [self addSubview:whiteView];
        self.whiteView = whiteView;
        
        
        /**
         会员出勤
         */
        UIButton *attendanceBtn = [[UIButton alloc] init];
        attendanceBtn.titleLabel.font = SmallFont;
        [attendanceBtn setTitleColor:CSColorFromRGB(0x0a0a0a)];
        [attendanceBtn setImage:@"icon_attendance"];
        [attendanceBtn setTitle:@"会员出勤"];
        [whiteView addSubview:attendanceBtn];
        self.attendanceBtn = attendanceBtn;
        
        /**
         短信群发
         */
        UIButton *messageBtn = [[UIButton alloc] init];
        messageBtn.titleLabel.font = SmallFont;
        [messageBtn setTitleColor:CSColorFromRGB(0x0a0a0a)];
        [messageBtn setImage:@"icon_gmessage"];
        [messageBtn setTitle:@"短信群发"];
        [whiteView addSubview:messageBtn];
        self.messageBtn = messageBtn;;
        
        /**
         导入导出
         */
        UIButton *exportBtn = [[UIButton alloc] init];
        exportBtn.titleLabel.font = SmallFont;
        [exportBtn setTitleColor:CSColorFromRGB(0x0a0a0a)];
        [exportBtn setImage:@"icon_export"];
        [exportBtn setTitle:@"导入导出"];
        [whiteView addSubview:exportBtn];
        self.exportBtn = exportBtn;
        
        /**
         生日提醒
         */
        UIButton *birthBtn = [[UIButton alloc] init];
        birthBtn.titleLabel.font = SmallFont;
        [birthBtn setTitleColor:CSColorFromRGB(0x0a0a0a)];
        [birthBtn setImage:@"icon_export"];
        [birthBtn setTitle:@"生日提醒"];
        [whiteView addSubview:birthBtn];
        self.birthBtn = birthBtn;
        
        /**
         等级管理
         */
        UIButton *levelBtn = [[UIButton alloc] init];
        levelBtn.titleLabel.font = SmallFont;
        [levelBtn setTitleColor:CSColorFromRGB(0x0a0a0a)];
        [levelBtn setImage:@"icon_management"];
        [levelBtn setTitle:@"等级管理"];
        [whiteView addSubview:levelBtn];
        self.levelBtn = levelBtn;
        
        UIButton *closeBtn = [[UIButton alloc] init];
        [closeBtn addTarget:self action:@selector(closeBtnClick)];
        [closeBtn setImage:@"icon_botclose"];        
        [whiteView addSubview:closeBtn];
        self.closeBtn = closeBtn;
        
        [self setConstraints];
    }
    
    return self;
}

-(void)setConstraints{
    
    [self.alphaView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.edges.mas_equalTo(self);
    }];
    
    [self.whiteView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.left.width.bottom.mas_equalTo(self);
    }];
    
    [self.closeBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.bottom.mas_equalTo(self.whiteView).offset(-5);
        
        make.centerX.mas_equalTo(self.whiteView);
    }];
    
    
    /**
     会员出勤
     */
    [self.attendanceBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.messageBtn);
        make.right.mas_equalTo(self.messageBtn.mas_left).offset(-20);
    }];
    
    /**
     短信群发
     */
    [self.messageBtn mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.top.mas_equalTo(self.exportBtn);
        make.right.mas_equalTo(self.exportBtn.mas_left).offset(-20);
    }];
    
    /**
     导入导出
     */
    [self.exportBtn mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.bottom.mas_equalTo(self.closeBtn.mas_top).offset(-20);
        make.top.mas_equalTo(self.whiteView).offset(20);
        make.centerX.mas_equalTo(self.whiteView);
    }];

    /**
     生日提醒
     */
    [self.birthBtn mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.top.mas_equalTo(self.exportBtn);
        make.left.mas_equalTo(self.exportBtn.mas_right).offset(20);
    }];

    /**
     等级管理
     */
    [self.levelBtn mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.top.mas_equalTo(self.birthBtn);
        make.left.mas_equalTo(self.birthBtn.mas_right).offset(20);
        //make.right.mas_equalTo(self.whiteView);
    }];
}

-(void)layoutSubviews{
    
    /**
     会员出勤
     */
    [self.attendanceBtn titleBelowTheImageWithSpace:10];
    
    /**
     短信群发
     */
    [self.messageBtn titleBelowTheImageWithSpace:10];
    
    /**
     导入导出
     */
    [self.exportBtn titleBelowTheImageWithSpace:10];
    
    /**
     生日提醒
     */
    [self.birthBtn titleBelowTheImageWithSpace:10];
    
    /**
     等级管理
     */
    [self.levelBtn titleBelowTheImageWithSpace:10];
}

#pragma mark 关闭按钮点击
-(void)closeBtnClick{
    
    [self removeFromSuperview];
}
@end
